package org.lex.utils;

public class SystemProperties {
	public static class Key {
		public static final String JAVA_CLASS_PATH = "java.class.path";
		public static final String JAVA_CLASS_VERSION = "java.class.version";
		public static final String JAVA_HOME = "java.home";
		public static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
		public static final String JAVA_LIBRARY_PATH = "java.library.path";
		public static final String JAVA_RUNTIME_NAME = "java.runtime.name";
		public static final String JAVA_RUNTIME_VERSION = "java.runtime.version";
		public static final String JAVA_SPECIFICATION_VERSION = "java.specification.version";
		public static final String JAVA_SPECIFICATION_VENDOR = "java.specification.vendor";
		public static final String JAVA_SPECIFICATION_NAME = "java.specification.name";
		public static final String JAVA_VENDOR = "java.vendor";
		public static final String JAVA_VENDOR_URL = "java.vendor.url";
		public static final String JAVA_VERSION = "java.version";
		public static final String JAVA_VM_INFO = "java.vm.info";
		public static final String JAVA_VM_NAME = "java.vm.name";
		public static final String JAVA_VM_VENDOR = "java.vm.vendor";
		public static final String JAVA_VM_VERSION = "java.vm.version";
		public static final String FILE_ENCODING = "file.encoding";
		public static final String FILE_SEPARATOR = "file.separator";
		public static final String LINE_SEPARATOR = "line.separator";
		public static final String PATH_SEPARATOR = "path.separator";
		public static final String OS_NAME = "os.name";
		public static final String OS_ARCH = "os.arch";
		public static final String OS_VERSION = "os.version";
		/**
		 * application start up dir
		 */
		public static final String USER_DIR = "user.dir";
		/**
		 * user home dir
		 */
		public static final String USER_HOME = "user.home";
		public static final String USER_NAME = "user.name";
		public static final String USER_COUNTRY = "user.country";
	}

	private SystemProperties() {
	}

	public static String get(String key) {
		return System.getProperty(key);
	}

	// ============= JVM =============
	public static String classPath() {
		return get(Key.JAVA_CLASS_PATH);
	}

	public static String javaHome() {
		return get(Key.JAVA_HOME);
	}

	public static String javaVersion() {
		return get(Key.JAVA_VERSION);
	}

	// =============== IO =============
	public static String tempDir() {
		return get(Key.JAVA_IO_TMPDIR);
	}

	public static String fileEncoding() {
		return get(Key.FILE_ENCODING);
	}

	public static String fileSeparator() {
		return get(Key.FILE_SEPARATOR);
	}

	public static String lineSeparator() {
		return get(Key.LINE_SEPARATOR);
	}

	public static String pathSeparator() {
		return get(Key.PATH_SEPARATOR);
	}

	// =========== OS =================
	public static String osArch() {
		return get(Key.OS_ARCH);
	}

	public static String osName() {
		return get(Key.OS_NAME);
	}

	public static String osVersion() {
		return get(Key.OS_VERSION);
	}

	// ================ User =================
	public static String userDir() {
		return get(Key.USER_DIR);
	}

	public static String userHome() {
		return get(Key.USER_HOME);
	}

	public static String userName() {
		return get(Key.USER_NAME);
	}

	/*
	 * Utilitie class
	 */
	public static class OS {
		private static boolean windows = false;
		private static String osName = "";
		static {
			osName = SystemProperties.osName();
			windows = osName.toLowerCase().startsWith("windows");
		}

		private OS() {
		}

		public static boolean isWindows() {
			return windows;
		}
	}
}
